-- treasure_get_material
-- created by wangy
-- 每获得一件宝物，额外获得材料

return {
    apply = function(prop, baseValue)
        return prop[3];
    end,

    -- 进入迷宫后获得材料抽取
    trigger = function(who, prop, arg)
        local rank = ItemM.query(arg, "rank");
        local seed = DungeonM.getRandSeed("treasure_get_material");
        local material = FormulaM.invoke("GET_MATERIAL_RANK", rank);

        local classId = material[1 + seed % #material];
        local ret = {1, classId, prop[3]};
        BonusM.doBonus(ret, "treasure_get_material");

        EventMgr.fire(event.TREASURE_GET_MATERIAL, { ["bonus"] = ret, });

        -- 触发特技发动事件
        -- EventMgr.fire(event.SPECIAL_SKILL_TRIGGER, { propId = prop[1] });
        return true;
    end,

    record = function(target, prop, path)
        return false;
    end
};
